<?php



$dep_id = isset($_GET['dep_id']) ? $_GET['dep_id'] : null;

if ($dep_id){

    require_once('./dbfunc.php');
    require_once('./dbparam.php');
    
    header('Content-Type: json');
    
    $conn = conn_mysql();
    
    $sql = "select te_id, te_name 
                from huangcz_te
                where te_dep = ?;";
    
    $stmt = $conn->prepare($sql);
    
    $stmt->bind_param('i', $dep_id);
    
    // 结果参数
    $te_name = '';
    $te_id = 0;
    
    $stmt->bind_result($te_id, $te_name);
    $stmt->execute();
    $stmt->store_result();
    
    // 响应内容
    $response = [];
    
    while ($stmt->fetch()){
        $response[] = [
            'te_id' => $te_id,
            'te_name' => $te_name
        ];
    }
    
    $stmt->free_result();

    exit(json_encode($response, JSON_UNESCAPED_UNICODE));
}else{
    exit(json_encode([]));
}







